package com.calvin.study;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import com.calvin.study.observer.event.MyEvent;
import com.calvin.study.observer.observer.IObserver;
import com.calvin.study.observer.subject.ISubject;
import com.calvin.study.strategy.spring.context.StrategyContext;
import com.calvin.study.strategy.strategy.Strategy;

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class Application {
	
	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
		MyEvent me = new MyEvent("event", "发布一个MyEvent事件");
		context.publishEvent(me);
		
	}
	
	@Autowired private ISubject subject;
	@Autowired private IObserver concreteObserverOne;
	@Autowired private IObserver concreteObserverTwo;
	@Autowired private IObserver concreteObserverThree;
	
	@Autowired private StrategyContext strategyContext;
	
	@PostConstruct
	public void executor() {
		//upgrade ConcreteSubject-->afterPropertiesSet()方法通过IOC容器注入所有的观察者对象
		//subject.register(concreteObserverOne);
		//subject.register(concreteObserverTwo);
		//subject.register(concreteObserverThree);
		
		//subject.notify("阿祖有行动！");
		
		Strategy s = StrategyContext.getStrategy("food");
		s.issue("123123");
	}
}
